Skip to content

fix(cli): bracket IPv6 bind literals in SSH forwards - #2552

Merged
mrunalp merged 1 commit into
NVIDIA:mainfrom
russellb:fix/issue-2279
Jul 29, 2026
Merged

fix(cli): bracket IPv6 bind literals in SSH forwards#2552
mrunalp merged 1 commit into
NVIDIA:mainfrom
russellb:fix/issue-2279

Conversation

@russellb

Copy link
Copy Markdown
Contributor

Summary

openshell forward start ::1:8080 <sandbox> built an invalid SSH local-forward argument and an invalid access URL because IPv6 bind literals were never bracketed. This fix brackets IPv6 literals so OpenSSH accepts the -L specification and the displayed URL is valid.

Related Issue

Fixes #2279

Changes

  • Extracted a shared bracket_ipv6_host() helper in crates/openshell-core/src/forward.rs.
  • ForwardSpec::ssh_forward_arg() now brackets IPv6 bind literals (::1:8080:127.0.0.1:8080[::1]:8080:127.0.0.1:8080), which OpenSSH accepts.
  • ForwardSpec::access_url() now formats via the existing format_gateway_url() helper, producing http://[::1]:8080/ while keeping the wildcard (::/0.0.0.0) → localhost display mapping.
  • Refactored format_gateway_url() to reuse the new helper (DRY).
  • Added regression tests covering IPv6 loopback and wildcard binds for both methods.

The reverse process-matching in ssh_forward_arg_matches_openshell_loopback_port matches on the :{port}:127.0.0.1:{port} suffix, so bracketed bind prefixes still match — background-forward validation is unaffected.

Testing

  • mise run pre-commit passes (Rust lint/format/tests clean; the unrelated pre-existing helm:lint chart-metadata error is not touched by this change)
  • Unit tests added/updated (forward_spec_ssh_forward_arg_brackets_ipv6_literal, forward_spec_access_url_ipv6)
  • E2E tests added/updated (if applicable) — not applicable; pure CLI argument-formatting fix covered by unit tests

Verified locally: cargo test -p openshell-core --lib (362 passed) and cargo test -p openshell-cli --lib ssh:: (40 passed).

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable) — not applicable

ForwardSpec accepts IPv6 bind addresses, but ssh_forward_arg() emitted
them unbracketed (e.g. ::1:8080:127.0.0.1:8080), which OpenSSH rejects
as a bad local forwarding specification. access_url() likewise produced
invalid URLs like http://::1:8080/.

Extract a shared bracket_ipv6_host() helper and use it in
ssh_forward_arg(), access_url() (via format_gateway_url), and
format_gateway_url() so IPv6 literals are bracketed consistently.

Fixes NVIDIA#2279

Signed-off-by: Russell Bryant <rbryant@redhat.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@mrunalp

mrunalp commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 280ea90

@mrunalp
mrunalp added this pull request to the merge queue Jul 29, 2026
Merged via the queue into NVIDIA:main with commit 0cecb54 Jul 29, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: support IPv6 bind addresses for SSH forwarding

2 participants